﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using DotSpatial.Topology;

using System.Drawing;

using System.Drawing.Drawing2D;

using Point = System.Drawing.Point;

namespace FXnaGis
{
    [Serializable]
   public class FTopologyShape:FShape
    {
        public FTopologyShape(string id)
            : base(id)
        {
 

        }

    


        public override DotSpatial.Data.Extent Extent
        {
            get
            {
                return new DotSpatial.Data.Extent(this._geometry.Envelope);
            }
        }



        Geometry _geometry;

        public Geometry Geometry
        {
            get { return _geometry; }
            set { _geometry = value; }
        }



        public override void Draw(FMapArgs args)
        {
          

            if (this._geometry is Polygon)
            {

                Polygon poly = this._geometry as Polygon;

                //我们之前还没有成功绘制过多边形，这里我们实验一下

                //先来画质外边界


                List<Point> ptsOutter = new List<Point>();


                foreach (Coordinate c in poly.Coordinates)
                {
                    ptsOutter.Add(args.ProjToPixel(c));
                    
                }


                args.Device.DrawLines(Pens.Black,ptsOutter.ToArray ());




                for (int i = 0; i < poly.Holes.Length; i++)
                {


                    List<Point> hole = new List<Point>();

                    foreach (Coordinate c in poly.Holes[i].Coordinates)
                    {
                        hole.Add(args.ProjToPixel(c));
                        
                    }

                    
                }

                

                

                //borderPath.StartFigure();
                //Point[] pointArray = intPoints.ToArray();
                //borderPath.AddLines(pointArray);


            }


        }

        public override bool Intersects(DotSpatial.Topology.Envelope envelope)
        {
            return this._geometry.Intersects(envelope);

        }


    }
}
